home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / src / test / testa.sml < prev    next >
Encoding:
Text File  |  1997-08-18  |  506 b   |  34 lines  |  [TEXT/R*ch]

  1. fun even 0 = true
  2.   | even x = odd(x-1)
  3. and odd  0 = false
  4.   | odd  x = even(x-1);
  5.  
  6. even 10; even 11;
  7.  
  8. datatype 'a X = X of string;
  9.  
  10. val stripX = fn X u => u;
  11. fn _ => stripX (X "OK");
  12. it () : string;
  13.  
  14. val stripX666 = fn X "666" => X "000" | x => x;
  15.  
  16. fn _ => stripX666 (X "666");
  17. it () : int X;
  18.  
  19. fn _ => stripX666 (X "OK");
  20. it () : int X;
  21.  
  22. datatype XXX =
  23.     A of int * int
  24.   | B of int * int;
  25.  
  26. val a12 = A(1,2)
  27. and b12 = B(1,2);
  28.  
  29. fun strip (A x) = x
  30.   | strip (B x) = x;
  31.  
  32. a12 = b12;
  33. strip a12 = strip b12;
  34.